<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><script type="text/javascript" src="https://cdn.jsdelivr.net/gh/opencobra/cobratoolbox@ffa0229fc0c01c9236bb7e961f65712443277719/latest/_static/js/iframeResizer.contentWindow.min.js"></script><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge,IE=9,chrome=1"><meta name="generator" content="MATLAB 2021a"><title>Visualize Elementary Flux Modes from E. coli model</title><style type="text/css">.rtcContent { padding: 30px; } .S0 { margin: 3px 10px 5px 4px; padding: 0px; line-height: 28.8px; min-height: 0px; white-space: normal; color: rgb(213, 80, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 24px; font-weight: normal; text-align: left;  }
.S1 { margin: 20px 10px 5px 4px; padding: 0px; line-height: 20px; min-height: 0px; white-space: normal; color: rgb(60, 60, 60); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: bold; text-align: left;  }
.S2 { margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: normal; text-align: left;  }
.S3 { margin: 10px 0px 20px; padding-left: 0px; font-family: Helvetica, Arial, sans-serif; font-size: 14px;  }
.S4 { margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: normal;  }
.S5 { margin: 3px 10px 5px 4px; padding: 0px; line-height: 20px; min-height: 0px; white-space: normal; color: rgb(60, 60, 60); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: bold; text-align: left;  }
.CodeBlock { background-color: #F7F7F7; margin: 10px 0 10px 0;}
.S6 { border-left: 1px solid rgb(233, 233, 233); border-right: 1px solid rgb(233, 233, 233); border-top: 1px solid rgb(233, 233, 233); border-bottom: 0px none rgb(0, 0, 0); border-radius: 4px 4px 0px 0px; padding: 6px 45px 0px 13px; line-height: 17.234px; min-height: 18px; white-space: nowrap; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px;  }
.S7 { border-left: 1px solid rgb(233, 233, 233); border-right: 1px solid rgb(233, 233, 233); border-top: 0px none rgb(0, 0, 0); border-bottom: 0px none rgb(0, 0, 0); border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 17.234px; min-height: 18px; white-space: nowrap; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px;  }
.S8 { border-left: 1px solid rgb(233, 233, 233); border-right: 1px solid rgb(233, 233, 233); border-top: 0px none rgb(0, 0, 0); border-bottom: 1px solid rgb(233, 233, 233); border-radius: 0px 0px 4px 4px; padding: 0px 45px 4px 13px; line-height: 17.234px; min-height: 18px; white-space: nowrap; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px;  }
.S9 { margin: 10px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: normal; text-align: left;  }
.S10 { border-left: 1px solid rgb(233, 233, 233); border-right: 1px solid rgb(233, 233, 233); border-top: 1px solid rgb(233, 233, 233); border-bottom: 1px solid rgb(233, 233, 233); border-radius: 4px; padding: 6px 45px 4px 13px; line-height: 17.234px; min-height: 18px; white-space: nowrap; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px;  }
.S11 { border-left: 1px solid rgb(233, 233, 233); border-right: 1px solid rgb(233, 233, 233); border-top: 1px solid rgb(233, 233, 233); border-bottom: 1px solid rgb(233, 233, 233); border-radius: 4px 4px 0px 0px; padding: 6px 45px 4px 13px; line-height: 17.234px; min-height: 18px; white-space: nowrap; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px;  }
.S12 { color: rgb(64, 64, 64); padding: 10px 0px 6px 17px; background: rgb(255, 255, 255) none repeat scroll 0% 0% / auto padding-box border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px; overflow-x: hidden; line-height: 17.234px;  }
.variableValue { width: 100% !important; }
.embeddedOutputsMatrixElement,.eoOutputWrapper .matrixElement {    min-height: 18px;    box-sizing: border-box;}
.embeddedOutputsMatrixElement .matrixElement,.eoOutputWrapper  .matrixElement,.rtcDataTipElement .matrixElement {    position: relative;}
.matrixElement .variableValue,.rtcDataTipElement .matrixElement .variableValue {    white-space: normal;    display: inline-block;    vertical-align: top;    overflow: hidden;}
.embeddedOutputsMatrixElement.inlineElement {}
.embeddedOutputsMatrixElement.inlineElement .topHeaderWrapper {    display: none;}
.embeddedOutputsMatrixElement.inlineElement .veTable .body {    padding-top: 0 !important;    max-height: 100px;}
.inlineElement .matrixElement {    max-height: 300px;}
.embeddedOutputsMatrixElement.rightPaneElement {}
.rightPaneElement .matrixElement,.rtcDataTipElement .matrixElement {    overflow: hidden;    padding-left: 9px;}
.rightPaneElement .matrixElement {    margin-bottom: -1px;}
.embeddedOutputsMatrixElement .matrixElement .valueContainer,.eoOutputWrapper .matrixElement .valueContainer,.rtcDataTipElement .matrixElement .valueContainer {    white-space: nowrap;    margin-bottom: 3px;}
.embeddedOutputsMatrixElement .matrixElement .valueContainer .horizontalEllipsis.hide,.embeddedOutputsMatrixElement .matrixElement .verticalEllipsis.hide,.eoOutputWrapper .matrixElement .valueContainer .horizontalEllipsis.hide,.eoOutputWrapper .matrixElement .verticalEllipsis.hide,.rtcDataTipElement .matrixElement .valueContainer .horizontalEllipsis.hide,.rtcDataTipElement .matrixElement .verticalEllipsis.hide {    display: none;}
.embeddedOutputsVariableMatrixElement .matrixElement .valueContainer.hideEllipses .verticalEllipsis, .embeddedOutputsVariableMatrixElement .matrixElement .valueContainer.hideEllipses .horizontalEllipsis {    display:none;}
.embeddedOutputsMatrixElement .matrixElement .valueContainer .horizontalEllipsis,.eoOutputWrapper .matrixElement .valueContainer .horizontalEllipsis {    margin-bottom: -3px;}
.eoOutputWrapper .embeddedOutputsVariableMatrixElement .matrixElement .valueContainer {    cursor: default !important;}
/* * Ellipses as base64 for HTML export. */.matrixElement .horizontalEllipsis,.rtcDataTipElement .matrixElement .horizontalEllipsis {    display: inline-block;    margin-top: 3px;    /* base64 encoded version of images-liveeditor/HEllipsis.png */    width: 30px;    height: 12px;    background-repeat: no-repeat;    background-image: url("");}
.matrixElement .verticalEllipsis,.textElement .verticalEllipsis,.rtcDataTipElement .matrixElement .verticalEllipsis,.rtcDataTipElement .textElement .verticalEllipsis {    margin-left: 35px;    /* base64 encoded version of images-liveeditor/VEllipsis.png */    width: 12px;    height: 30px;    background-repeat: no-repeat;    background-image: url("");}
.S13 { border-left: 1px solid rgb(233, 233, 233); border-right: 1px solid rgb(233, 233, 233); border-top: 1px solid rgb(233, 233, 233); border-bottom: 1px solid rgb(233, 233, 233); border-radius: 0px; padding: 6px 45px 4px 13px; line-height: 17.234px; min-height: 18px; white-space: nowrap; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px;  }
.S14 { border-left: 1px solid rgb(233, 233, 233); border-right: 1px solid rgb(233, 233, 233); border-top: 0px none rgb(0, 0, 0); border-bottom: 1px solid rgb(233, 233, 233); border-radius: 0px; padding: 0px 45px 4px 13px; line-height: 17.234px; min-height: 18px; white-space: nowrap; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px;  }
/* Styling that is common to warnings and errors is in diagnosticOutput.css */.embeddedOutputsErrorElement {    min-height: 18px;    max-height: 250px;    overflow: auto;}
.embeddedOutputsErrorElement.inlineElement {}
.embeddedOutputsErrorElement.rightPaneElement {}
/* Styling that is common to warnings and errors is in diagnosticOutput.css */.embeddedOutputsWarningElement{    min-height: 18px;    max-height: 250px;    overflow: auto;}
.embeddedOutputsWarningElement.inlineElement {}
.embeddedOutputsWarningElement.rightPaneElement {}
/* Copyright 2015-2019 The MathWorks, Inc. *//* In this file, styles are not scoped to rtcContainer since they could be in the Dojo Tooltip */.diagnosticMessage-wrapper {    font-family: Menlo, Monaco, Consolas, "Courier New", monospace;    font-size: 12px;}
.diagnosticMessage-wrapper.diagnosticMessage-warningType {    color: rgb(255,100,0);}
.diagnosticMessage-wrapper.diagnosticMessage-warningType a {    color: rgb(255,100,0);    text-decoration: underline;}
.diagnosticMessage-wrapper.diagnosticMessage-errorType {    color: rgb(230,0,0);}
.diagnosticMessage-wrapper.diagnosticMessage-errorType a {    color: rgb(230,0,0);    text-decoration: underline;}
.diagnosticMessage-wrapper .diagnosticMessage-messagePart,.diagnosticMessage-wrapper .diagnosticMessage-causePart {    white-space: normal;}
.diagnosticMessage-wrapper .diagnosticMessage-stackPart {    white-space: normal;}
.embeddedOutputsTextElement,.embeddedOutputsVariableStringElement {    white-space: normal;    word-wrap:  initial;    min-height: 18px;    max-height: 250px;    overflow: auto;}
.textElement,.rtcDataTipElement .textElement {    padding-top: 3px;}
.embeddedOutputsTextElement.inlineElement,.embeddedOutputsVariableStringElement.inlineElement {}
.inlineElement .textElement {}
.embeddedOutputsTextElement.rightPaneElement,.embeddedOutputsVariableStringElement.rightPaneElement {    min-height: 16px;}
.rightPaneElement .textElement {    padding-top: 2px;    padding-left: 9px;}
.S15 { border-left: 1px solid rgb(233, 233, 233); border-right: 1px solid rgb(233, 233, 233); border-top: 1px solid rgb(233, 233, 233); border-bottom: 0px none rgb(0, 0, 0); border-radius: 0px; padding: 6px 45px 0px 13px; line-height: 17.234px; min-height: 18px; white-space: nowrap; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px;  }</style></head><body><div class = rtcContent><h1  class = 'S0'><span>Visualize Elementary Flux Modes from </span><span style=' font-style: italic;'>E. coli</span><span> model</span></h1><h2  class = 'S1'><span>Author(s): Chaitra Sarathy (Maastricht University, The Netherlands)</span></h2><h2  class = 'S1'><span>Reviewer(s): </span></h2><div  class = 'S2'><span style=' font-style: italic;'>Include those who have reviewed the tutorial, and are therefore partly responsible for picking up errors or omissions.</span></div><h2  class = 'S1'><span>INTRODUCTION</span></h2><div  class = 'S2'><span>Elementary Flux Modes (EFMs) are a tool for constraint-based modelling and metabolic network analysis. However, systematic and automated visualization of EFMs, capable of integrating various data types is still a challenge. This tutorial is part of the study by Sarathy et al. (2019, in preparation), "EFMviz: A COBRA Toolbox extension to visualize Elementary Flux Modes in genome-scale metabolic models". </span></div><div  class = 'S2'><span>This workflow can be used to visualize EFMs calculated using any currently available methods. Inputs for the workflow are: (1) the text file containing EFMs and (2) the genome-scale metabolic model used for generating EFMs. Additionally, omics data can be used to select one (or more) EFM(s) for visualization among the vast number of EFMs that usually results from EFM calculation. Sarathy et al. (2019, in preparation) demonstrate two examples of such a selection procedure (a) Yield Analysis and (b) EFM Enrichment with EFMs calculated from genome-scale metabolic models, (1) iAF1260 (E. coli) [1] and (2) Recon 2.2 (Human) [2]. </span></div><div  class = 'S2'><span>Each use case is explained with a tutorial. This tutorial corresponds to the first use case and it describes how to analyze and visualize EFMs from the </span><span style=' font-style: italic;'>E. coli </span><span>model iAF1260</span><span style=' font-style: italic;'>. </span><span>The aim is to apply the workflow on a small-scale model and it can be used as a means to study acetate overflow metabolism in E. coli. EFMs were generated for glucose uptake reaction. For details on how EFMs were generated, please refer the citation section at </span><a href = "https://github.com/macsbio/efmviz"><span>https://github.com/macsbio/efmviz</span></a></div><div  class = 'S2'><span>The steps in the workflow include:</span></div><div  class = 'S2'><span>        </span><span style=' font-weight: bold;'>A. Specifying Inputs: </span></div><div  class = 'S2'><span>        i. Import input data: file containing EFMs (.txt), model file (.mat), file containing relative fluxes for active reactions in EFM (.txt)</span></div><div  class = 'S2'><span>        (Note: relative fluxes are usually calculated during EFM generation. if this file is not available, fluxomics data can also be used instead)</span></div><div  class = 'S2'><span>       </span><span style=' font-weight: bold;'> B. EFM Selection</span></div><div  class = 'S2'><span>        i. Filter EFMs containing a reaction of interest</span></div><div  class = 'S2'><span>        ii. Calculate yields using the fluxes imported in step A</span></div><div  class = 'S2'><span>        iii. Select EFMs with desired value of yield, for example, highest and lowest yield</span></div><div  class = 'S2'><span>       </span><span style=' font-weight: bold;'>C. Submodel Creation</span></div><div  class = 'S2'><span>        i. Write submodel (with ubiquitous metabolites)</span></div><div  class = 'S2'><span>        ii. Write submodel (withOUT ubiquitous metabolites)</span></div><div  class = 'S2'><span>        iii. Identify backbone: Extract reactions occurring in a certain percentage of EFMs</span></div><div  class = 'S2'><span>        iv. Extract flux data for mapping on the visualized EFM</span></div><div  class = 'S2'><span>        </span><span style=' font-weight: bold;'>D. Visualization</span></div><div  class = 'S2'><span>        Open the SBML file in Cytoscape and map the data used during step B.</span></div><div  class = 'S2'><span>The following sections will walk you through the code for performing the steps A-D, thereby reproducing the main results from Sarathy et al (2019, in preparation) (Use Case 1). For more details on the workflow please refer </span><a href = "https://github.com/macsbio/efmviz"><span>https://github.com/macsbio/efmviz</span></a></div><div  class = 'S2'><span style=' font-weight: bold;'>Input File Formats</span></div><ul  class = 'S3'><li  class = 'S4'><span>model (.mat): same as the model used for EFM generation </span></li><li  class = 'S4'><span>file containing EFMs (.txt): each row corresponds to an EFM and column has indices of reactions active in the EFM. Each row can have varied number of columns. The first column should contain an EFM ID.</span></li><li  class = 'S4'><span>file containing relative fluxes (.txt):</span></li></ul><h2  class = 'S5'><span>PROCEDURE</span></h2><h2  class = 'S1'><span style=' font-style: italic;'>A. Specifying Input</span><span> </span></h2><div  class = 'S2'><span>First, declare all the input variables such as file paths and filenames of input files and output files.</span></div><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S6'><span style="white-space: normal"><span style="color: rgb(2, 128, 9);">% File names and location</span></span></div></div><div class="inlineWrapper"><div  class = 'S7'><span style="white-space: normal"><span >modelFileLocation = strcat(pwd, filesep); </span></span></div></div><div class="inlineWrapper"><div  class = 'S7'><span style="white-space: normal"><span >modelFileName = </span><span style="color: rgb(170, 4, 249);">'iAF1260_irr.mat'</span><span >;</span></span></div></div><div class="inlineWrapper"><div  class = 'S7'></div></div><div class="inlineWrapper"><div  class = 'S7'><span style="white-space: normal"><span >efmFileLocation = strcat(pwd, filesep);</span></span></div></div><div class="inlineWrapper"><div  class = 'S7'><span style="white-space: normal"><span >efmFileName = </span><span style="color: rgb(170, 4, 249);">'EFM-acetate-E10000-729.txt'</span><span >;</span></span></div></div><div class="inlineWrapper"><div  class = 'S7'></div></div><div class="inlineWrapper"><div  class = 'S7'><span style="white-space: normal"><span >fluxFileLocation = strcat(pwd, filesep);</span></span></div></div><div class="inlineWrapper"><div  class = 'S7'><span style="white-space: normal"><span >fluxFileName = </span><span style="color: rgb(170, 4, 249);">'FV-acetate-E10000-729.dat.txt'</span><span >;</span></span></div></div><div class="inlineWrapper"><div  class = 'S7'></div></div><div class="inlineWrapper"><div  class = 'S7'><span style="white-space: normal"><span style="color: rgb(2, 128, 9);">% Prefixes for the output files </span></span></div></div><div class="inlineWrapper"><div  class = 'S7'><span style="white-space: normal"><span >organism = </span><span style="color: rgb(170, 4, 249);">'ecoli'</span><span >;</span></span></div></div><div class="inlineWrapper"><div  class = 'S7'><span style="white-space: normal"><span >dataFile = </span><span style="color: rgb(170, 4, 249);">'dataForMapping_EFM'</span><span >;</span></span></div></div><div class="inlineWrapper"><div  class = 'S7'><span style="white-space: normal"><span >efmBackboneFile = </span><span style="color: rgb(170, 4, 249);">'efmBackbone'</span><span >;</span></span></div></div><div class="inlineWrapper"><div  class = 'S7'><span style="white-space: normal"><span >efmPercentage = </span><span style="color: rgb(170, 4, 249);">'_EFM_percentage_'</span><span >;</span></span></div></div><div class="inlineWrapper"><div  class = 'S7'><span style="white-space: normal"><span >dataFileExt = </span><span style="color: rgb(170, 4, 249);">'.txt'</span><span >;</span></span></div></div><div class="inlineWrapper"><div  class = 'S7'><span style="white-space: normal"><span >sbmlExt = </span><span style="color: rgb(170, 4, 249);">'.xml'</span><span >;</span></span></div></div><div class="inlineWrapper"><div  class = 'S7'><span style="white-space: normal"><span >efmPre = </span><span style="color: rgb(170, 4, 249);">'_EFM_'</span><span >;</span></span></div></div><div class="inlineWrapper"><div  class = 'S8'><span style="white-space: normal"><span >metRem = </span><span style="color: rgb(170, 4, 249);">'_woUbMet_'</span><span >;</span></span></div></div></div><div  class = 'S9'><span>Also define the numeric indices of reactions of interest i.e., acetate release and glucose uptake, which will be used for calculating yield.</span></div><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S6'><span style="white-space: normal"><span >roi_glcUp = 2594; </span><span style="color: rgb(2, 128, 9);">% glucose uptake (EX_glc__D_e_b)</span></span></div></div><div class="inlineWrapper"><div  class = 'S8'><span style="white-space: normal"><span >roi_acRel = 729; </span><span style="color: rgb(2, 128, 9);">% acetate exchange (EX_ac_e, also the active reaction for EFM Generation)</span></span></div></div></div><div  class = 'S9'><span>If you know the reaction ID from the model, the corresponding index can be calculated as:</span></div><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: normal"><span style="color: rgb(2, 128, 9);">% index = find(contains(model_irr.rxns, 'EX_ac_e')); % gives 729 as output</span></span></div></div></div><div  class = 'S9'><span style=' font-weight: bold; font-style: italic;'>i. Import model, EFMs and relative reaction fluxes</span></div><div  class = 'S2'><span>Load the same model that was used for generating set of EFMs. Here, iAF1260 was converted to a model containing only unidirectional (irreversible) reactions for EFM calculation.</span></div><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: normal"><span >model_irr = importdata([modelFileLocation modelFileName]);</span></span></div></div></div><div  class = 'S9'><span>Alternatively, xml model file can also be used. In that case, use the COBRA function </span><span style=' font-style: italic;'>readCbModel.</span></div><div  class = 'S2'><span>Then, import the files containing EFMs and relative fluxes in EFMs (usually results from EFM caculation) and set values below 0.001 to 0. </span></div><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S6'><span style="white-space: normal"><span >[EFMRxns, EFMFluxes] = efmImport(efmFileLocation, efmFileName, fluxFileLocation, fluxFileName);</span></span></div></div><div class="inlineWrapper"><div  class = 'S8'><span style="white-space: normal"><span >EFMFluxes(EFMFluxes &lt; 1e-3) = 0;</span></span></div></div></div><div  class = 'S9'><span style=' font-weight: bold; text-decoration: underline;'>TIMING</span><span>: For large models and large set of EFMs, this step can take a few seconds to couple of minutes.</span></div><h2  class = 'S5'><span style=' font-style: italic;'>B. EFM Selection</span></h2><div  class = 'S2'><span style=' font-weight: bold; font-style: italic;'>i. Filter EFMs</span></div><div  class = 'S2'><span>Next, retain EFMs containing the acetate release reaction for further analysis and extract corresponding rows from the imported fluxes.</span></div><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S6'><span style="white-space: normal"><span >[filteredEFMs, filteredRows] = efmFilter(EFMRxns, roi_glcUp); </span></span></div></div><div class="inlineWrapper"><div  class = 'S8'><span style="white-space: normal"><span >filteredFluxes = EFMFluxes(filteredRows, :);</span></span></div></div></div><div  class = 'S9'><span>All the EFMs contain both glucose uptake and acetate release reactions. If necessary, the above step can be repeated with additional reactions of interest, for example, oxygen uptake.</span></div><div  class = 'S2'><span style=' font-weight: bold; font-style: italic;'>ii. Yield calculation</span></div><div  class = 'S2'><span>A crucial step in calculating yield is the choice of input and output reactions of interest, i.e., uptake of a substrate and excretion of a product, following which yield is simply calculated by dividing the output flux by the reference input flux. Calculate yield of acetate release on glucose input for all the subset of EFMs.</span></div><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: normal"><span >EFMyield = efmYieldAnalysis(EFMFluxes, roi_glcUp, roi_acRel);    </span></span></div></div></div><div  class = 'S9'><span>Once you have the yields, get the index of EFMs with highest and lowest yield.</span></div><div class="CodeBlock"><div class="inlineWrapper outputs"><div  class = 'S11'><span style="white-space: normal"><span >find(EFMyield == min(EFMyield)) </span></span></div><div  class = 'S12'><div class="inlineElement eoOutputWrapper embeddedOutputsMatrixElement" uid="D90E4476" data-scroll-top="null" data-scroll-left="null" data-width="428" data-testid="output_0" style="width: 458px;"><div class="matrixElement veSpecifier"><div class="veVariableName variableNameElement" style="width: 428px;"><span>ans = </span><span class="veVariableValueSummary"></span></div><div class="valueContainer" data-layout="{&quot;columnWidth&quot;:43.2,&quot;totalColumns&quot;:&quot;1&quot;,&quot;totalRows&quot;:&quot;84&quot;,&quot;charsPerColumn&quot;:6}"><div class="variableValue" style="width: 45.2px;">   781
   782
   794
   799
   803
   825
   829
   844
   859
   860
</div><div class="horizontalEllipsis hide"></div><div class="verticalEllipsis"></div></div></div></div></div></div><div class="inlineWrapper outputs"><div  class = 'S13'><span style="white-space: normal"><span >find(EFMyield == max(EFMyield))       </span></span></div><div  class = 'S12'><div class='variableElement' style='font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 12px; '>ans = 18</div></div></div></div><div  class = 'S9'><span style=' font-weight: bold; font-style: italic;'>iii. Select EFM with highest and lowest yield</span></div><div  class = 'S2'><span>EFM 18 has the highest acetate yield on glucose</span></div><div  class = 'S2'><span>EFM 885 is the shortest EFM, among 84 EFMs that have lowest acetate yield on glucose </span></div><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: normal"><span >selectedEFM = 885;</span></span></div></div></div><div  class = 'S9'><span>Once you have selected an EFM, you can extract the reactions in the EFM as a submodel (SMBL file) as explained below in C (Submodel Creation). This SBML file will be imported into Cytoscape in step D. You can choose to extract the SBML file with or without molecules that are connected to several reactions such as ATP and H2O using step C.i. or C.ii. respectively. We reccommend removing highly connected metabolites to improve the readability of the visualized network. In cases of analyzing/visualizing several EFMs, you can first visualize without ubquitous molecules to understand the underlying process and then look at the corresponding network with ubiquitous molecules.</span></div><div  class = 'S2'><span>An SBML file will be generated as output in each substep - C.i., C.ii. and C.iii. You can choose to run one step at a time. Follow the instructions in step D for each SBML file that you want to visualize.</span></div><h2  class = 'S5'><span style=' font-style: italic;'>C. Submodel Creation</span></h2><div  class = 'S2'><span style=' font-weight: bold; font-style: italic;'>i. Write submodel (with ubiquitous metabolites)</span></div><div  class = 'S2'><span>Get the indices of all reactions present in the selected EFM and extract it as a SBML file.</span></div><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S6'><span style="white-space: normal"><span >selectedRxns = EFMRxns(selectedEFM, find(EFMRxns(selectedEFM,:))); </span></span></div></div><div class="inlineWrapper outputs"><div  class = 'S14'><span style="white-space: normal"><span >efmSubmodelExtractionAsSBML(model_irr, selectedRxns, char(strcat(organism, efmPre, string(selectedEFM), sbmlExt)));</span></span></div><div  class = 'S12'><div class="inlineElement eoOutputWrapper embeddedOutputsTextElement" uid="977ADD7A" data-scroll-top="null" data-scroll-left="null" data-width="428" data-height="18" data-hashorizontaloverflow="false" data-testid="output_2" style="max-height: 261px; width: 458px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">Document written</div></div></div></div></div><div  class = 'S9'><span>SBML file with all the metabolites is written in the current working directory.</span></div><div  class = 'S2'><span style=' font-weight: bold; text-decoration: underline;'>TIMING</span><span>: Writing SBML file could take a few seconds</span></div><div  class = 'S2'><span style=' font-weight: bold; font-style: italic;'>ii. Write submodel (withOUT ubiquitous metabolites)</span></div><div  class = 'S2'><span>Define the list of ubiquitous metabolites to be removed, making sure that the metabolite IDs match those in the model. Extract it as a SBML file</span></div><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S6'><span style="white-space: normal"><span >ubiquitousMets = {</span><span style="color: rgb(170, 4, 249);">'h'</span><span >;</span><span style="color: rgb(170, 4, 249);">'h2'</span><span >;</span><span style="color: rgb(170, 4, 249);">'fe3'</span><span >;</span><span style="color: rgb(170, 4, 249);">'fe2'</span><span >;</span><span style="color: rgb(170, 4, 249);">'h2o'</span><span >;</span><span style="color: rgb(170, 4, 249);">'na1'</span><span >;</span><span style="color: rgb(170, 4, 249);">'atp'</span><span >;</span><span style="color: rgb(170, 4, 249);">'datp'</span><span >;</span><span style="color: rgb(170, 4, 249);">'hco3'</span><span >;</span><span style="color: rgb(170, 4, 249);">'pi'</span><span >;</span><span style="color: rgb(170, 4, 249);">'adp'</span><span >;</span><span style="color: rgb(170, 4, 249);">'dadp'</span><span >;</span><span style="color: rgb(170, 4, 249);">'nadp'</span><span >;</span><span style="color: rgb(170, 4, 249);">'nadph'</span><span >;</span><span style="color: rgb(170, 4, 249);">'coa'</span><span >;</span><span style="color: rgb(170, 4, 249);">'o2'</span><span >;</span><span style="color: rgb(170, 4, 249);">'nad'</span><span >;</span><span style="color: rgb(170, 4, 249);">'nadh'</span><span >;</span><span style="color: rgb(170, 4, 249);">'ppi'</span><span >;</span><span style="color: rgb(170, 4, 249);">'pppi'</span><span >;</span><span style="color: rgb(170, 4, 249);">'amp'</span><span >;</span><span style="color: rgb(170, 4, 249);">'so4'</span><span >;</span><span style="color: rgb(170, 4, 249);">'fad'</span><span >;</span><span style="color: rgb(170, 4, 249);">'fadh2'</span><span >;</span><span style="color: rgb(170, 4, 249);">'udp'</span><span >;</span><span style="color: rgb(170, 4, 249);">'dudp'</span><span >;</span><span style="color: rgb(170, 4, 249);">'co2'</span><span >;</span><span style="color: rgb(170, 4, 249);">'h2o2'</span><span >;</span><span style="color: rgb(170, 4, 249);">'nh4'</span><span >;</span><span style="color: rgb(170, 4, 249);">'ctp'</span><span >;</span><span style="color: rgb(170, 4, 249);">'utp'</span><span >;</span><span style="color: rgb(170, 4, 249);">'gtp'</span><span >;</span><span style="color: rgb(170, 4, 249);">'cdp'</span><span >;</span><span style="color: rgb(170, 4, 249);">'gdp'</span><span >;</span><span style="color: rgb(170, 4, 249);">'dcdp'</span><span >;</span><span style="color: rgb(170, 4, 249);">'dgdp'</span><span >;</span><span style="color: rgb(170, 4, 249);">'dtdp'</span><span >;</span><span style="color: rgb(170, 4, 249);">'dctp'</span><span >;</span><span style="color: rgb(170, 4, 249);">'dttp'</span><span >;</span><span style="color: rgb(170, 4, 249);">'dutp'</span><span >;</span><span style="color: rgb(170, 4, 249);">'dgtp'</span><span >;</span><span style="color: rgb(170, 4, 249);">'cmp'</span><span >;</span><span style="color: rgb(170, 4, 249);">'gmp'</span><span >;</span><span style="color: rgb(170, 4, 249);">'ump'</span><span >;</span><span style="color: rgb(170, 4, 249);">'dcmp'</span><span >;</span><span style="color: rgb(170, 4, 249);">'dtmp'</span><span >;</span><span style="color: rgb(170, 4, 249);">'dgmp'</span><span >;</span><span style="color: rgb(170, 4, 249);">'dump'</span><span >;</span><span style="color: rgb(170, 4, 249);">'damp'</span><span >;</span><span style="color: rgb(170, 4, 249);">'cl'</span><span >;</span><span style="color: rgb(170, 4, 249);">'q8'</span><span >;</span><span style="color: rgb(170, 4, 249);">'q8h2'</span><span >;</span><span style="color: rgb(170, 4, 249);">'2dmmq8'</span><span >};</span></span></div></div><div class="inlineWrapper outputs"><div  class = 'S14'><span style="white-space: normal"><span >efmSubmodelExtractionAsSBML(model_irr, selectedRxns, char(strcat(organism, efmPre, string(selectedEFM), metRem, sbmlExt)), 1, ubiquitousMets);</span></span></div><div  class = 'S12'><div class="inlineElement eoOutputWrapper embeddedOutputsTextElement" uid="CC58D40E" data-scroll-top="null" data-scroll-left="null" data-width="428" data-height="18" data-hashorizontaloverflow="false" data-testid="output_3" style="max-height: 261px; width: 458px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">Document written</div></div></div></div></div><div  class = 'S9'><span>SBML file withOUT all the specified metabolites is written in the current working directory.</span></div><div  class = 'S2'><span>In addition to looking at single EFMs, you can also use this workflow to extract an "EFM Backbone", i.e., commonly occurring reactions in the EFMs A certain percentage can be used as an input criteria , for example, 80%, 50%, 25%.</span></div><div  class = 'S2'><span style=' font-weight: bold; font-style: italic;'>iii. Identify backbone: Extract reactions occurring in a certain percentage of EFMs</span></div><div  class = 'S2'><span>First, set the desired percentage and extract the reactions that are present in 'percentage' of EFMs. Input this set of reactions to the function 'efmSubmodelExtractionAsSBML' to write it out as an SBML file.</span></div><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S6'><span style="white-space: normal"><span >percentage = 65;</span></span></div></div><div class="inlineWrapper"><div  class = 'S7'><span style="white-space: normal"><span >[selectedRxns_bb,  rxnDistribution] = efmBackboneExtraction(EFMRxns, percentage);</span></span></div></div><div class="inlineWrapper"><div  class = 'S7'><span style="white-space: normal"><span >rxnDistribution.rxnName = model_irr.rxns(rxnDistribution.rxnID);</span></span></div></div><div class="inlineWrapper outputs"><div  class = 'S14'><span style="white-space: normal"><span >efmSubmodelExtractionAsSBML(model_irr, selectedRxns_bb.rxnID, char(strcat(organism, efmPercentage, string(percentage), sbmlExt)), 1, ubiquitousMets);</span></span></div><div  class = 'S12'><div class="inlineElement eoOutputWrapper embeddedOutputsTextElement" uid="4DD0C00B" data-scroll-top="null" data-scroll-left="null" data-width="428" data-height="18" data-hashorizontaloverflow="false" data-testid="output_4" style="max-height: 261px; width: 458px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">Document written</div></div></div></div><div class="inlineWrapper"><div  class = 'S15'></div></div><div class="inlineWrapper"><div  class = 'S7'><span style="white-space: normal"><span style="color: rgb(2, 128, 9);">% % [OPTIONAL] Plot the number of reactions present in different proportion of EFMs and save this data in a text and map on visualized network</span></span></div></div><div class="inlineWrapper"><div  class = 'S7'><span style="white-space: normal"><span style="color: rgb(2, 128, 9);">% figure; h = histogram(rxnDistribution.efmOccPercentage,20);</span></span></div></div><div class="inlineWrapper"><div  class = 'S7'><span style="white-space: normal"><span style="color: rgb(2, 128, 9);">% x = h.BinEdges;</span></span></div></div><div class="inlineWrapper"><div  class = 'S7'><span style="white-space: normal"><span style="color: rgb(2, 128, 9);">% y = h.Values;</span></span></div></div><div class="inlineWrapper"><div  class = 'S7'><span style="white-space: normal"><span style="color: rgb(2, 128, 9);">% text(x(1:end-1),y,num2str(y'),'vert','bottom','horiz','left');</span></span></div></div><div class="inlineWrapper"><div  class = 'S8'><span style="white-space: normal"><span style="color: rgb(2, 128, 9);">% writetable(rxnDistribution, strcat(organism, dataFile, '_', efmBackboneFile, dataFileExt));</span></span></div></div></div><div  class = 'S9'><span>SBML file with all the reactions in the 'backbone' is written in the current working directory.</span></div><div  class = 'S2'><span style=' font-weight: bold; font-style: italic;'>iv. Extract flux data for mapping on the visualized EFM</span></div><div  class = 'S2'><span>This is an optional step. Post visualization, the same fluxes can also be mapped on the network, which requires reaction ID and corresponding fluxes. Write it as a text file which will be imported in Cytoscape in step D.</span></div><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S6'><span style="white-space: normal"><span >selectedFlux = EFMFluxes(selectedEFM, selectedRxns);</span></span></div></div><div class="inlineWrapper"><div  class = 'S7'><span style="white-space: normal"><span >selectedFlux = selectedFlux';</span></span></div></div><div class="inlineWrapper"><div  class = 'S8'><span style="white-space: normal"><span >writetable(table(model_irr.rxns(selectedRxns),selectedFlux,</span><span style="color: rgb(170, 4, 249);">'VariableNames'</span><span >,{</span><span style="color: rgb(170, 4, 249);">'Reactions'</span><span >,</span><span style="color: rgb(170, 4, 249);">'Flux'</span><span >}), strcat(organism, dataFile, </span><span style="color: rgb(170, 4, 249);">'_'</span><span >, string(selectedEFM), dataFileExt));</span></span></div></div></div><h2  class = 'S5'><span>D. Visualization</span></h2><div  class = 'S2'><span>Follow these steps for each submodel SBML file that you wish to visualize.</span></div><ul  class = 'S3'><li  class = 'S4'><span>Make sure Cytoscape (v3 and above) is installed along with cy3sbml (app) and yFiles layout</span></li><li  class = 'S4'><span>Open the SBML file using the cy3sbml app. [Click on the cy3sbl app-specific icon and select the EFM submodel file to open. For every file imported, three networks are generated and are identified using the prefixes: All, Base and Kinetic. Use the Base network for rest of the tutorial.</span></li></ul><div  class = 'S2'><img class = "imageNode" src = "" alt = "" style = "vertical-align: baseline"></img></div><ul  class = 'S3'><li  class = 'S4'><span>Import the style file supplied with this workflow (efmviz_style.xml) and apply this style on the Base network. You can now see a network with three different types of nodes representing reactions, genes and metabolites and edges representing interaction between these molecule types. This is how your EFM looks!</span></li><li  class = 'S4'><span>Set the layout using Layout -&gt; yFiles Orthogonal layout. In our experience orthogonal layout works best for EFMs with 50-60 reactions. Beyond that, the EFM can be visualized, but will be difficult to interpret.</span></li><li  class = 'S4'><span>(Optionally) Import the data file generated in step C.iv to map on the reaction edges. Use the R script (see below for details)</span></li></ul><div  class = 'S2'><span>For running this step on several files, follow instructions in the R script, efmviz_rcy3_ecol.Rmd.</span></div><div  class = 'S2'><span style=' font-weight: bold; text-decoration: underline;'>Try it yourself</span><span style=' font-weight: bold;'>:</span><span> To visualize other EFMs, such as 885, just by change the variable 'selectedEFM' and repeat steps C and D .</span></div><h2  class = 'S1'><span>REFERENCES</span></h2><div  class = 'S2'><span>[1] Feist, A.M.; Henry, C.S.; Reed, J.L.; Krummenacker, M.; Joyce, A.R.; Karp, P.D.; Broadbelt, L.J.;Hatzimanikatis, V.; Palsson, B.Ø. A genome-scale metabolic reconstruction for Escherichia coli K-12 MG1655 that accounts for 1260 ORFs and thermodynamic information. Molecular Systems Biology 2007, 3, 121. doi:10.1038/MSB4100155.</span></div><div  class = 'S2'><span>[2] Swainston, N.; Smallbone, K.; Hefzi, H.; Dobson, P.D.; Brewer, J.; Hanscho, M.; Zielinski, D.C.; Ang, K.S.; Gardiner, N.J.; Gutierrez, J.M.; Kyriakopoulos, S.; Lakshmanan, M.; Li, S.; Liu, J.K.; Martínez, V.S.; Orellana, C.A.; Quek, L.E.; Thomas, A.; Zanghellini, J.; Borth, N.; Lee, D.Y.; Nielsen, L.K.; Kell, D.B.; Lewis, N.E.; Mendes, P. Recon 2.2: from reconstruction to model of human metabolism. Metabolomics 2016, 12, 109. doi:10.1007/s11306-016-1051-4.</span></div><div  class = 'S2'></div>
<br>
<!-- 
##### SOURCE BEGIN #####
%% Visualize Elementary Flux Modes from _E. coli_ model
%% Author(s): Chaitra Sarathy (Maastricht University, The Netherlands)
%% Reviewer(s): 
% _Include those who have reviewed the tutorial, and are therefore partly responsible 
% for picking up errors or omissions._
%% INTRODUCTION
% Elementary Flux Modes (EFMs) are a tool for constraint-based modelling and 
% metabolic network analysis. However, systematic and automated visualization 
% of EFMs, capable of integrating various data types is still a challenge. This 
% tutorial is part of the study by Sarathy et al. (2019, in preparation), "EFMviz: 
% A COBRA Toolbox extension to visualize Elementary Flux Modes in genome-scale 
% metabolic models". 
% 
% This workflow can be used to visualize EFMs calculated using any currently 
% available methods. Inputs for the workflow are: (1) the text file containing 
% EFMs and (2) the genome-scale metabolic model used for generating EFMs. Additionally, 
% omics data can be used to select one (or more) EFM(s) for visualization among 
% the vast number of EFMs that usually results from EFM calculation. Sarathy et 
% al. (2019, in preparation) demonstrate two examples of such a selection procedure 
% (a) Yield Analysis and (b) EFM Enrichment with EFMs calculated from genome-scale 
% metabolic models, (1) iAF1260 (E. coli) [1] and (2) Recon 2.2 (Human) [2]. 
% 
% Each use case is explained with a tutorial. This tutorial corresponds to the 
% first use case and it describes how to analyze and visualize EFMs from the _E. 
% coli_ model iAF1260_._ The aim is to apply the workflow on a small-scale model 
% and it can be used as a means to study acetate overflow metabolism in E. coli. 
% EFMs were generated for glucose uptake reaction. For details on how EFMs were 
% generated, please refer the citation section at <https://github.com/macsbio/efmviz 
% https://github.com/macsbio/efmviz>
% 
% The steps in the workflow include:
% 
% *A. Specifying Inputs:* 
% 
% i. Import input data: file containing EFMs (.txt), model file (.mat), file 
% containing relative fluxes for active reactions in EFM (.txt)
% 
% (Note: relative fluxes are usually calculated during EFM generation. if this 
% file is not available, fluxomics data can also be used instead)
% 
% *B. EFM Selection*
% 
% i. Filter EFMs containing a reaction of interest
% 
% ii. Calculate yields using the fluxes imported in step A
% 
% iii. Select EFMs with desired value of yield, for example, highest and lowest 
% yield
% 
% *C. Submodel Creation*
% 
% i. Write submodel (with ubiquitous metabolites)
% 
% ii. Write submodel (withOUT ubiquitous metabolites)
% 
% iii. Identify backbone: Extract reactions occurring in a certain percentage 
% of EFMs
% 
% iv. Extract flux data for mapping on the visualized EFM
% 
% *D. Visualization*
% 
% Open the SBML file in Cytoscape and map the data used during step B.
% 
% The following sections will walk you through the code for performing the steps 
% A-D, thereby reproducing the main results from Sarathy et al (2019, in preparation) 
% (Use Case 1). For more details on the workflow please refer <https://github.com/macsbio/efmviz 
% https://github.com/macsbio/efmviz>
% 
% *Input File Formats*
%% 
% * model (.mat): same as the model used for EFM generation 
% * file containing EFMs (.txt): each row corresponds to an EFM and column has 
% indices of reactions active in the EFM. Each row can have varied number of columns. 
% The first column should contain an EFM ID.
% * file containing relative fluxes (.txt):
%% PROCEDURE
%% _A. Specifying Input_ 
% First, declare all the input variables such as file paths and filenames of 
% input files and output files.

% File names and location
modelFileLocation = strcat(pwd, filesep); 
modelFileName = 'iAF1260_irr.mat';

efmFileLocation = strcat(pwd, filesep);
efmFileName = 'EFM-acetate-E10000-729.txt';

fluxFileLocation = strcat(pwd, filesep);
fluxFileName = 'FV-acetate-E10000-729.dat.txt';

% Prefixes for the output files 
organism = 'ecoli';
dataFile = 'dataForMapping_EFM';
efmBackboneFile = 'efmBackbone';
efmPercentage = '_EFM_percentage_';
dataFileExt = '.txt';
sbmlExt = '.xml';
efmPre = '_EFM_';
metRem = '_woUbMet_';
%% 
% Also define the numeric indices of reactions of interest i.e., acetate release 
% and glucose uptake, which will be used for calculating yield.

roi_glcUp = 2594; % glucose uptake (EX_glc__D_e_b)
roi_acRel = 729; % acetate exchange (EX_ac_e, also the active reaction for EFM Generation)
%% 
% If you know the reaction ID from the model, the corresponding index can be 
% calculated as:

% index = find(contains(model_irr.rxns, 'EX_ac_e')); % gives 729 as output
%% 
% _*i. Import model, EFMs and relative reaction fluxes*_
% 
% Load the same model that was used for generating set of EFMs. Here, iAF1260 
% was converted to a model containing only unidirectional (irreversible) reactions 
% for EFM calculation.

model_irr = importdata([modelFileLocation modelFileName]);
%% 
% Alternatively, xml model file can also be used. In that case, use the COBRA 
% function _readCbModel._
% 
% Then, import the files containing EFMs and relative fluxes in EFMs (usually 
% results from EFM caculation) and set values below 0.001 to 0. 

[EFMRxns, EFMFluxes] = efmImport(efmFileLocation, efmFileName, fluxFileLocation, fluxFileName);
EFMFluxes(EFMFluxes < 1e-3) = 0;
%% 
% *TIMING*: For large models and large set of EFMs, this step can take a few 
% seconds to couple of minutes.
%% _B. EFM Selection_
% _*i. Filter EFMs*_
% 
% Next, retain EFMs containing the acetate release reaction for further analysis 
% and extract corresponding rows from the imported fluxes.

[filteredEFMs, filteredRows] = efmFilter(EFMRxns, roi_glcUp); 
filteredFluxes = EFMFluxes(filteredRows, :);
%% 
% All the EFMs contain both glucose uptake and acetate release reactions. If 
% necessary, the above step can be repeated with additional reactions of interest, 
% for example, oxygen uptake.
% 
% _*ii. Yield calculation*_
% 
% A crucial step in calculating yield is the choice of input and output reactions 
% of interest, i.e., uptake of a substrate and excretion of a product, following 
% which yield is simply calculated by dividing the output flux by the reference 
% input flux. Calculate yield of acetate release on glucose input for all the 
% subset of EFMs.

EFMyield = efmYieldAnalysis(EFMFluxes, roi_glcUp, roi_acRel);    
%% 
% Once you have the yields, get the index of EFMs with highest and lowest yield.

find(EFMyield == min(EFMyield)) 
find(EFMyield == max(EFMyield))       
%% 
% _*iii. Select EFM with highest and lowest yield*_
% 
% EFM 18 has the highest acetate yield on glucose
% 
% EFM 885 is the shortest EFM, among 84 EFMs that have lowest acetate yield 
% on glucose 

selectedEFM = 885;
%% 
% Once you have selected an EFM, you can extract the reactions in the EFM as 
% a submodel (SMBL file) as explained below in C (Submodel Creation). This SBML 
% file will be imported into Cytoscape in step D. You can choose to extract the 
% SBML file with or without molecules that are connected to several reactions 
% such as ATP and H2O using step C.i. or C.ii. respectively. We reccommend removing 
% highly connected metabolites to improve the readability of the visualized network. 
% In cases of analyzing/visualizing several EFMs, you can first visualize without 
% ubquitous molecules to understand the underlying process and then look at the 
% corresponding network with ubiquitous molecules.
% 
% An SBML file will be generated as output in each substep - C.i., C.ii. and 
% C.iii. You can choose to run one step at a time. Follow the instructions in 
% step D for each SBML file that you want to visualize.
%% _C. Submodel Creation_
% _*i. Write submodel (with ubiquitous metabolites)*_
% 
% Get the indices of all reactions present in the selected EFM and extract it 
% as a SBML file.

selectedRxns = EFMRxns(selectedEFM, find(EFMRxns(selectedEFM,:))); 
efmSubmodelExtractionAsSBML(model_irr, selectedRxns, char(strcat(organism, efmPre, string(selectedEFM), sbmlExt)));
%% 
% SBML file with all the metabolites is written in the current working directory.
% 
% *TIMING*: Writing SBML file could take a few seconds
% 
% _*ii. Write submodel (withOUT ubiquitous metabolites)*_
% 
% Define the list of ubiquitous metabolites to be removed, making sure that 
% the metabolite IDs match those in the model. Extract it as a SBML file

ubiquitousMets = {'h';'h2';'fe3';'fe2';'h2o';'na1';'atp';'datp';'hco3';'pi';'adp';'dadp';'nadp';'nadph';'coa';'o2';'nad';'nadh';'ppi';'pppi';'amp';'so4';'fad';'fadh2';'udp';'dudp';'co2';'h2o2';'nh4';'ctp';'utp';'gtp';'cdp';'gdp';'dcdp';'dgdp';'dtdp';'dctp';'dttp';'dutp';'dgtp';'cmp';'gmp';'ump';'dcmp';'dtmp';'dgmp';'dump';'damp';'cl';'q8';'q8h2';'2dmmq8'};
efmSubmodelExtractionAsSBML(model_irr, selectedRxns, char(strcat(organism, efmPre, string(selectedEFM), metRem, sbmlExt)), 1, ubiquitousMets);
%% 
% SBML file withOUT all the specified metabolites is written in the current 
% working directory.
% 
% In addition to looking at single EFMs, you can also use this workflow to extract 
% an "EFM Backbone", i.e., commonly occurring reactions in the EFMs A certain 
% percentage can be used as an input criteria , for example, 80%, 50%, 25%.
% 
% _*iii. Identify backbone: Extract reactions occurring in a certain percentage 
% of EFMs*_
% 
% First, set the desired percentage and extract the reactions that are present 
% in 'percentage' of EFMs. Input this set of reactions to the function 'efmSubmodelExtractionAsSBML' 
% to write it out as an SBML file.

percentage = 65;
[selectedRxns_bb,  rxnDistribution] = efmBackboneExtraction(EFMRxns, percentage);
rxnDistribution.rxnName = model_irr.rxns(rxnDistribution.rxnID);
efmSubmodelExtractionAsSBML(model_irr, selectedRxns_bb.rxnID, char(strcat(organism, efmPercentage, string(percentage), sbmlExt)), 1, ubiquitousMets);

% % [OPTIONAL] Plot the number of reactions present in different proportion of EFMs and save this data in a text and map on visualized network
% figure; h = histogram(rxnDistribution.efmOccPercentage,20);
% x = h.BinEdges;
% y = h.Values;
% text(x(1:end-1),y,num2str(y'),'vert','bottom','horiz','left');
% writetable(rxnDistribution, strcat(organism, dataFile, '_', efmBackboneFile, dataFileExt));
%% 
% SBML file with all the reactions in the 'backbone' is written in the current 
% working directory.
% 
% _*iv. Extract flux data for mapping on the visualized EFM*_
% 
% This is an optional step. Post visualization, the same fluxes can also be 
% mapped on the network, which requires reaction ID and corresponding fluxes. 
% Write it as a text file which will be imported in Cytoscape in step D.

selectedFlux = EFMFluxes(selectedEFM, selectedRxns);
selectedFlux = selectedFlux';
writetable(table(model_irr.rxns(selectedRxns),selectedFlux,'VariableNames',{'Reactions','Flux'}), strcat(organism, dataFile, '_', string(selectedEFM), dataFileExt));
%% D. Visualization
% Follow these steps for each submodel SBML file that you wish to visualize.
%% 
% * Make sure Cytoscape (v3 and above) is installed along with cy3sbml (app) 
% and yFiles layout
% * Open the SBML file using the cy3sbml app. [Click on the cy3sbl app-specific 
% icon and select the EFM submodel file to open. For every file imported, three 
% networks are generated and are identified using the prefixes: All, Base and 
% Kinetic. Use the Base network for rest of the tutorial.
%% 
% 
%% 
% * Import the style file supplied with this workflow (efmviz_style.xml) and 
% apply this style on the Base network. You can now see a network with three different 
% types of nodes representing reactions, genes and metabolites and edges representing 
% interaction between these molecule types. This is how your EFM looks!
% * Set the layout using Layout -> yFiles Orthogonal layout. In our experience 
% orthogonal layout works best for EFMs with 50-60 reactions. Beyond that, the 
% EFM can be visualized, but will be difficult to interpret.
% * (Optionally) Import the data file generated in step C.iv to map on the reaction 
% edges. Use the R script (see below for details)
%% 
% For running this step on several files, follow instructions in the R script, 
% efmviz_rcy3_ecol.Rmd.
% 
% *Try it yourself:* To visualize other EFMs, such as 885, just by change the 
% variable 'selectedEFM' and repeat steps C and D .
%% REFERENCES
% [1] Feist, A.M.; Henry, C.S.; Reed, J.L.; Krummenacker, M.; Joyce, A.R.; Karp, 
% P.D.; Broadbelt, L.J.;Hatzimanikatis, V.; Palsson, B.Ø. A genome-scale metabolic 
% reconstruction for Escherichia coli K-12 MG1655 that accounts for 1260 ORFs 
% and thermodynamic information. Molecular Systems Biology 2007, 3, 121. doi:10.1038/MSB4100155.
% 
% [2] Swainston, N.; Smallbone, K.; Hefzi, H.; Dobson, P.D.; Brewer, J.; Hanscho, 
% M.; Zielinski, D.C.; Ang, K.S.; Gardiner, N.J.; Gutierrez, J.M.; Kyriakopoulos, 
% S.; Lakshmanan, M.; Li, S.; Liu, J.K.; Martínez, V.S.; Orellana, C.A.; Quek, 
% L.E.; Thomas, A.; Zanghellini, J.; Borth, N.; Lee, D.Y.; Nielsen, L.K.; Kell, 
% D.B.; Lewis, N.E.; Mendes, P. Recon 2.2: from reconstruction to model of human 
% metabolism. Metabolomics 2016, 12, 109. doi:10.1007/s11306-016-1051-4.
% 
%
##### SOURCE END #####
-->
</div></body></html>